﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Sac.Web;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.IsAuthenticated)
            Response.Redirect("Default.aspx");
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string userName = textUserName.Text.Trim();
        string password = textPassword.Text.Trim();
        UserRoleOperate user = new UserRoleOperate();
        string roleId = user.Login(userName, password);
        if (roleId == "")
        {
            lblLoginMessage.Text = "用户名或密码错误";
        }
        else
        {
            FormsAuthentication.RedirectFromLoginPage(userName, false);
            RolePowerOperate role = new RolePowerOperate();
            string power = role.GetPowerCodeById(roleId);
            Session.Timeout = 120;
            Session["UserName"] = userName;
            Session["RolePower"] = power;
        }
    }
}
